import type { LotteryType } from '@/enums/lottery'
import type { Prize } from './Prize'
import { PrizeLevel } from '@/enums/prize'
import type { Winner } from './Winner'

export class Lottery {
  private type: LotteryType

  private prizeMap: Map<PrizeLevel, Prize>

  private currentPrizeLevel: PrizeLevel

  constructor(type: LotteryType, prizeMap: Map<PrizeLevel, Prize>) {
    this.type = type
    this.prizeMap = prizeMap
    this.currentPrizeLevel = PrizeLevel.FIRST_PRIZE
  }

  getType() {
    return this.type
  }

  setCurrentPrizeLevel(value: PrizeLevel) {
    this.currentPrizeLevel = value
  }

  getPrizes() {
    return [...this.prizeMap.values()]
  }

  private getPrize() {
    return this.prizeMap.get(this.currentPrizeLevel) as Prize
  }

  getPrizeLevel() {
    const prize = this.getPrize()
    return prize.getPrizeLevel()
  }

  getPrizeName() {
    const prize = this.getPrize()
    return prize.getName()
  }

  getWinnersSize() {
    const prize = this.getPrize()
    return prize.getNumberOfWinners()
  }

  getWinners() {
    const prize = this.getPrize()
    return prize.getNumberOfWinners()
  }

  setWinners(value: number) {
    const prize = this.getPrize()
    prize.setNumberOfDraws(value)
  }

  getNumberOfDraws() {
    const prize = this.getPrize()
    return prize.getNumberOfDraws()
  }

  setNumberOfDraws(value: number) {
    const prize = this.getPrize()
    prize.setNumberOfDraws(value)
  }
}
